package cn.edu.dlmu.cogo.register;

import cn.hutool.core.date.TimeInterval;

/**
 * @author hongda.li@hand-china.com 2022/3/10 21:01
 */
public class ServiceInstance {

    private String serviceName;

    private String serviceHost;

    private String serviceIp;

    private int servicePort;

    private String startTime;

    private boolean enableState = false;

    private final TimeInterval interval = new TimeInterval();

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getServiceHost() {
        return serviceHost;
    }

    public void setServiceHost(String serviceHost) {
        this.serviceHost = serviceHost;
    }

    public String getServiceIp() {
        return serviceIp;
    }

    public void setServiceIp(String serviceIp) {
        this.serviceIp = serviceIp;
    }

    public int getServicePort() {
        return servicePort;
    }

    public void setServicePort(int servicePort) {
        this.servicePort = servicePort;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public boolean isEnableState() {
        return enableState;
    }

    public void setEnableState(boolean enableState) {
        this.enableState = enableState;
    }

    public long getInterval() {
        return interval.intervalSecond();
    }

    public void startInterval() {
        this.interval.start();
    }

    public void restartInterval(){
        this.interval.restart();
    }

    @Override
    public String toString() {
        return "ServiceInstance{" +
                "serviceName='" + serviceName + '\'' +
                ", serviceHost='" + serviceHost + '\'' +
                ", serviceIp='" + serviceIp + '\'' +
                ", servicePort=" + servicePort +
                ", startTime='" + startTime + '\'' +
                ", enableState=" + enableState +
                '}';
    }
}
